#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#include "vector.h"

class test_std_vector
{	
public:
	void test1()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);

		for (size_t i = 0; i < v1.size(); i++)
		{
			cout << v1[i] << ' ';
		}
		cout << endl;

		vector<int> v2(v1.begin(), v1.end());
		for (size_t i = 0; i < v2.size(); i++)
		{
			cout << v2[i] << ' ';
		}
		cout << endl;

		string str = "He had an argument with his family!!!";
		vector<char> v3(str.begin(), str.end());
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
		auto pos = find(v3.begin(), v3.end(), ' ');
		while (pos != v3.end())
		{
			pos = v3.erase(pos);
			pos = find(pos, v3.end(), ' ');
		}
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
		sort(v3.rbegin(), v3.rend());
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
	}
	void test2()
	{
		string str = "It was a wild night";
		vector<char> v1(str.begin(), str.end());
		// cout << v1[str.size()] << endl;
		for (auto i : v1)
		{
			cout << i;
		}
		cout << endl;
		v1.insert(v1.begin() + 128, 5, '!');
		for (auto i : v1)
		{
			cout << i;
		}
		cout << endl;
		v1.erase(v1.begin() + 15, v1.end());
		/*cout << v1.at(256) << endl;*/
		/*v1.erase(v1.end());*/
	}
};
class test_simulation_vector
{
public:
	void test1()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto v1_it = v1.begin();
		while (v1_it != v1.end())
		{
			cout << *v1_it << ' ';
			++v1_it;
		}
		cout << endl;
		for (size_t i = 0; i < v1.size(); i++)
		{
			v1[i]++;
		}
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
	void test2()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto pos = v1.begin();
		v1.insert(pos, 100);

		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto pos_1 = v1.begin();
		v1.erase(pos_1);
		v1.erase(pos_1);
		v1.erase(pos_1); 
		v1.erase(pos_1);
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
};
int main()
{
	test_simulation_vector().test2();

	return 0;
}